package cmd

import (
	"github.com/spf13/cobra"
	global2 "longmen/server/config/global"
	"longmen/server/internal/services/consumers/config"
	_const "longmen/server/pkg/common/helper/const"
)

var test = &cobra.Command{
	Use:   "test",
	Short: "运行统计相关的consumer ",
	Long:  "运行统计相关的consumer,  可分布式运行，只需注意资源利用即可",
	Run: func(cmd *cobra.Command, args []string) {
		//test := []stats.PublishStats{}
		//for i := 0; i < 100000; i++ {
		//	test = append(test, stats.PublishStats{
		//		StatType:   stats.StatType(gofakeit.IntRange(1, 3)),
		//		SenderUid:     gofakeit.IntRange(600000, 700000),
		//		DeviceUUID: uuid.New().String(),
		//		ClientIp:   gofakeit.IPv4Address(),
		//		PlatForm:   int8(gofakeit.IntRange(1, 3)),
		//	})
		//}
		//
		//for _, publishStats := range test {
		//	marshal, _ := json.Marshal(publishStats)
		//	fmt.Println(string(marshal))
		//	_ = global.PublisherStatistic.StatisticPush(publishStats.StatType, publishStats.SenderUid, publishStats.DeviceUUID, publishStats.ClientIp, publishStats.PlatForm)
		//}
		//crontab.UserStats()
		//_ = global.PublisherStatistic.StatisticPush(stats.UsageStatistic, 1, uuid.New().String(), "127.0.0.1", 1)

		//_ = global.PublisherStatistic.StatisticPush(stats.RegisterStatistic, 2, uuid.New().String(), "127.0.0.1", 2)

		//_ = global.PublisherStatistic.StatisticPush(stats.LoginStatistic, 3, "-", "127.0.0.1", 3)
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		global2.AppName = _const.PusherStatistic
		global2.Initialize(config.ConfigPath)
		config.InitConsumerConfig()
		global2.InitPublisher()
	},
}
